---
import { getEnv } from '../../lib/env'
import voidFile from '../../assets/void.png'
import List from '../../components/list.astro'
import { getChannelInfo } from '../../lib/telegram'

const { SITE_URL } = Astro.locals

const channelInfo = await getChannelInfo(Astro)

const post = await getChannelInfo(Astro, {
  type: 'post',
  id: Astro.params.id,
})

const channel = {
  ...(channelInfo || {}),
  posts: [post],
  seo: post,
}

const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
---

<List channel={channel} before={false} after={false} isItem={true}>
  <div slot="header" id="breadcrumb">
    <img
      src={channel?.avatar?.startsWith('http') ? staticProxy + channel?.avatar : voidFile.src}
      alt={channel?.title}
      loading="eager"
      class="breadcrumb-avatar"
    />
    <div class="breadcrumb-title">
      <a href={SITE_URL} class="site-title" title={channel?.title}>
        {channel.title}
      </a>
    </div>
  </div>
</List>
